package com.yscp.ysdemo.exception;

import com.yscp.ysdemo.constant.ResultEnum;

//自定义异常携带状态码是为了后面统一处理异常时能往前端塞对应的状态码

/**
 * 顶层业务异常类
 */
public class BusinessException extends RuntimeException{

    //状态码
    private Integer code;

    //枚举类赋值
    public BusinessException(ResultEnum resultEnum){
        super(resultEnum.getMsg());
        code = resultEnum.getCode();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public BusinessException(String msg){
        super(msg);
    }
    public BusinessException(){
        super();
    }

}
